<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>深入理解promise的then</h1>
<hr>

<script>
    let func = function () {
        return new Promise((resolve, reject) => {
            resolve('成功');
        });
    };
    let foo = function () {
        console.log('一定要执行foo方法...');
        return 'foo';
    }
    func().then(function () {
        return foo();
    }).then(resp => {
        console.warn(resp);
        console.warn('1 =========>');
    });

    func().then(function () {
        foo();
    }).then(resp => {
        console.warn(resp);
        console.warn('2 =========>');
    });

    func().then(foo()).then(resp => {
        console.warn(resp);
        console.warn('3 =========>');
    });

    func().then(foo).then(resp => {
        console.warn(resp);
        console.warn('4 =========>');
    });
</script>
</body>
</html>